package org.journal.entity;

// Generated Dec 18, 2014 11:06:01 AM by Hibernate Tools 4.0.0

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Calendar;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * UserEntity generated by hbm2java
 */
@NamedQueries(value = { @NamedQuery(name = "UserEntity.getUserByName", query = "Select user from UserEntity user where username=:username") })
@Entity
@Table(name = "user", catalog = "journal")
public class UserEntity implements java.io.Serializable {

	private Integer idUser;
	private String username;
	private String password;
	private boolean enabled;
	private Calendar creationDate;
	private Set<RecordEntity> recordEntities = new HashSet<RecordEntity>(0);
	private Set<AuthoritiesEntity> authoritiesEntities = new HashSet<AuthoritiesEntity>(
			0);

	public UserEntity() {
	}

	public UserEntity(String username, String password, boolean enabled,
			Calendar creationDate) {
		this.username = username;
		this.password = password;
		this.enabled = enabled;
		this.creationDate = creationDate;
	}

	public UserEntity(String username, String password, boolean enabled,
			Calendar creationDate, Set<RecordEntity> recordEntities,
			Set<AuthoritiesEntity> authoritiesEntities) {
		this.username = username;
		this.password = password;
		this.enabled = enabled;
		this.creationDate = creationDate;
		this.recordEntities = recordEntities;
		this.authoritiesEntities = authoritiesEntities;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id_user", unique = true, nullable = false)
	public Integer getIdUser() {
		return this.idUser;
	}

	public void setIdUser(Integer idUser) {
		this.idUser = idUser;
	}

	@Column(name = "username", nullable = false, length = 100)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "password", nullable = false, length = 100)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "enabled", nullable = false)
	public boolean isEnabled() {
		return this.enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "creation_date", nullable = false, length = 19)
	public Calendar getCreationDate() {
		return this.creationDate;
	}

	public void setCreationDate(Calendar creationDate) {
		this.creationDate = creationDate;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "userEntity")
	public Set<RecordEntity> getRecordEntities() {
		return this.recordEntities;
	}

	public void setRecordEntities(Set<RecordEntity> recordEntities) {
		this.recordEntities = recordEntities;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "userEntity")
	public Set<AuthoritiesEntity> getAuthoritiesEntities() {
		return this.authoritiesEntities;
	}

	public void setAuthoritiesEntities(
			Set<AuthoritiesEntity> authoritiesEntities) {
		this.authoritiesEntities = authoritiesEntities;
	}

}
